package com.java.demo.string;

/**
 * @auther zhangwj
 * @date 2020/8/21 5:50 下午
 */
public class Demo2 {


    private volatile Data data = new Data("111111");

    private void num(Data data) {
        data = new Data("22222222");
        System.out.println(data);
    }

    public static void main(String[] args) {
        Demo2 demo2 = new Demo2();
        System.out.println(demo2.data);
        demo2.num(demo2.data);
        System.out.println(demo2.data);
    }
}

class Data {

    private String data;

    Data(String data) {
        this.data = data;
    }

    public String getData() {
        return data;
    }

    public void setData(String data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "Data{" +
                "data='" + data + '\'' +
                '}';
    }
}
